package com.study.modules.saas.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.study.modules.saas.repository.dao.UserRoleDao;
import com.study.modules.saas.repository.model.UserRoleDO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Description: 用户菜单
 * @ClassName: UserRoleService
 * @Author: hupengming
 * @CreateTime: 2022-08-26 17:21
 */
@Service
public class UserRoleService {

    @Autowired
    UserRoleDao userRoleDao;

    /**
     * 用户和角色关联数，根据roleId 获得
     *
     * @param roleId
     * @return
     */
    public Integer getUserRoleByRoleIdCount(Integer roleId){
        return userRoleDao.selectCount(new LambdaQueryWrapper<UserRoleDO>().eq(UserRoleDO::getRoleId,roleId));
    }

    /**
     * 物理删除用户和角色关联 根据roleId
     *
     * @param roleId
     * @return
     */
    public Integer deleteUserRoleByRoleId(Integer roleId){
        return userRoleDao.delete(new LambdaQueryWrapper<UserRoleDO>().eq(UserRoleDO::getRoleId,roleId));
    }

}
